﻿@{
    ViewBag.Title = Resources.AdminSite;
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}
<div class="clearfix">
    <table id="publisherList" class="scroll" cellpadding="0" cellspacing="0">
    </table>
    <div id="publisherPager" class="scroll" style="text-align: center;">
    </div>
</div>
<script type="text/javascript">

    var editImageUrl = '@Url.Content("~/Content/images/ico-edit.gif")';
    var deleteImageUrl = '@Url.Content("~/Content/images/ico-delete.gif")';
    var createUrl = '@Url.Content("~/Admin/Publisher/Create/")';
    var updateUrl = '@Url.Content("~/Admin/Publisher/Update/")';
    var deleteUrl = '@Url.Content("~/Admin/Publisher/Delete/")';
    var getdataUrl = '@Url.Content("~/Admin/Publisher/GetGridData/")';

    Sys.require(["jqGrid"],
      function () {
          var grid = $("#publisherList").jqGrid({
              url: getdataUrl,
              datatype: 'json',
              mtype: 'GET',
              width: 640,
              height: 230,
              colNames: ['@Resources.PublisherGridID', '@Resources.PublisherGridName', '@Resources.GridEditHeader', '@Resources.GridDeleteHeader'],
              colModel: [
                  { name: 'ID', index: 'ID', width: 40, align: 'center', editable: false },
                  { name: 'Name', index: 'Name', width: 200, align: 'center', editable: true },
                  { name: 'EditColumn', index: 'Edit', width: 40, align: 'center', stype: 'null' },
                  { name: 'DeleteColumn', index: 'Delete', width: 40, align: 'center', stype: 'null'}],
              pager: '#publisherPager',
              rowNum: 10,
              rowList: [10, 20],
              viewrecords: true,
              jsonReader: {
                  root: "Rows",
                  page: "PageIndex",
                  total: "TotalPages",
                  records: "TotalCount",
                  repeatitems: false,
                  userdata: "UserData",
                  id: "ID"
              },
              multiselect: false,
              loadComplete: function () {
                  {
                      afterLoadComplete.call
                    ($('#publisherList'), updateUrl, "EditColumn", editImageUrl, 'afterClickEdit', '@Resources.EditPublisherTitle');
                  }
                  {
                      afterLoadComplete.call
                    ($('#publisherList'), deleteUrl, "DeleteColumn", deleteImageUrl, 'afterClickDelete', '@Resources.DeletePublisherTitle');
                  }
              }
          })
        .navGrid('#publisherPager', { edit: false, add: true, del: false, search: false }, {},
          {
              reloadAfterSubmit: true,
              url: createUrl,
              addCaption: '@Resources.AddPublisherTitle',
              modal: true,
              closeAfterAdd: true,
              afterSubmit: processErrorAfterSubmit
          });
      }); 
        
</script>
